package com.zzy;

import okhttp3.*;

import java.io.IOException;

public class OkHttpClientExample {
    public static void main(String[] args) {
        String url = "https://api.coze.cn/v1/workflow/run";
        String token = "Bearer pat_FEE9HzVm4GXSTVPkAavfyjB1anHNBPhwcGndiBle6jKaIiuyjOyX65Cwj5r9V41q";
        String contentType = "application/json";

        String requestBody = "{\n" +
                "  \"workflow_id\": \"7527176968987901990\",\n" +
                "  \"parameters\": {\n" +
                "    \"article_url\": \"https://news.cctv.cn/2025/10/17/ARTIwzEI5i2g3WiPAyYMBQLY251017.shtml\"\n" +
                "  }\n" +
                "}";

        OkHttpClient client = new OkHttpClient();

        Request request = new Request.Builder()
                .url(url)
                .post(RequestBody.create(MediaType.parse(contentType), requestBody))
                .addHeader("Authorization", token)
                .build();

        try (Response response = client.newCall(request).execute()) {
            if (response.body() != null) {
                System.out.println(response.body().string());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
